package com.mcintyret.site.context;

import com.mcintyret.site.web.model.ModelDataSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;

import java.util.Map;

/**
 * User: mcintyret2
 * Date: 28/03/2012
 */

@ModelDataSource
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class UserContext {

    private boolean loggedIn;
    private boolean admin;

    private String username;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public int getHitsPerPage(String url) {
        Integer hitsForPage = hitsPerPage.get(url);
        return hitsForPage == null ? 0 : hitsForPage;
    }

    public void setHitsPerPage(Map<String, Integer> hitsPerPage) {
        this.hitsPerPage = hitsPerPage;
    }

    private Map<String, Integer> hitsPerPage;

    public boolean isLoggedIn() {
        return loggedIn;
    }

    public void setLoggedIn(boolean loggedIn) {
        this.loggedIn = loggedIn;
    }

    public boolean isAdmin() {
        return admin;
    }

    public void setAdmin(boolean admin) {
        this.admin = admin;
    }


}
